# ffmpeg
# Builds from https://github.com/puppylinux-woof-CE/petbuilds

. ../func
. ../build.conf

URL=https://www.ffmpeg.org/releases
PKG=ffmpeg
#VER=2.2.9
VER=2.6.1
COMP=tar.bz2
DESC="FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything"
DEPS=+sdl,+x264,+speex,+libogg,+libvorbis,+faac,+libvpx,+schroedinger,+libtheora,+lame
CAT=Multimedia
DESKTOP=ffmpeg.desktop
BUILD=
CWD=$(pwd)
[ -z "$MWD" ] && MWD=$(dirname $CWD)	
[ -z "$BUILD" ] && BUILD=$DEF_BUILD
#[ -f "$DESKTOP" ] || DESKTOP=not
[ -z "$DEPS" ] && DEPS=not	

ARCH=$(uname -m)
case $ARCH in
 *64) 	LIBDIR=$LIBCONF64 ;;
 arm*)	LIBDIR=$LIBCONFarm;;
 *) 	LIBDIR=$LIBCONF32 ;;
esac

build() {
	cd ${PKG}-${VER}
	./configure --prefix=/usr \
				--libdir=/usr/${LIBDIR} \
				--enable-libmp3lame \
				--enable-libx264 \
				--enable-libfaac \
				--enable-pthreads \
				--enable-small \
				--enable-postproc \
				--enable-libvorbis \
				--enable-gpl \
				--enable-shared \
				--enable-nonfree \
				--enable-libopencore-amrnb \
				--enable-libopencore-amrwb \
				--disable-debug \
				--enable-bzlib \
				--enable-zlib \
				--enable-libspeex \
				--enable-version3 \
				--enable-runtime-cpudetect \
				--enable-x11grab \
				--enable-libschroedinger \
				--enable-libtheora \
				--enable-libxvid  \
				--enable-swscale \
				--enable-libvpx
	[ "$?" -eq 0 ] || exit
	make $MKFLG
	[ "$?" -eq 0 ] || exit
	make DESTDIR=$CWD/${PKG}-install install
	cd -
}
	
package() {
	# this is a woeful bug in ffmeg install
	if [ "$ARCH" = "x86_64" ];then
		cp -a ${PKG}-install/usr/lib/* ${PKG}-install/usr/lib64
		rm -r ${PKG}-install/usr/lib
	fi
}

# main
retrieve "${PKG}-${VER}.${COMP} --no-check-certificate"
extract ${PKG}-${VER}.${COMP}
build
package
package_std $PKG $VER $ARCH $DESKTOP "$DESC" $DEPS $CAT	
